const arr = ["flower","flow","flight"]
var longestCommonPrefix = function(strs) {
   if(strs.length===0) return "";
   let ant = arr[0];
   for(let i = 1;i<strs.length;i++){
    let j = 0;
    for(;j<ant.length&&j<strs[i].length;j++){
        if(ant[j]!==strs[i][j])
            break;
    }
    ant = ant.slice(0,j);
    if(ant==="") return "";
   }
   return ant;
};
console.log(longestCommonPrefix(arr))
